package com.diy.sigmund.diycommon.designpatterns.strategy.exceimport;

import java.util.Objects;

/**
 * @author ylm-sigmund
 * @since 2020/11/30 17:45
 */
public enum ExcelImportEnum {

    /** 实例枚举 */
    ONEEXCELIMPORT("oneExcelImport",new OneExcelImport()),

    TWOEXCELIMPORT("twoExcelImport",new TwoExcelImport());
    private final String name;
    private final ExcelImport excelImport;

    ExcelImportEnum(String name, ExcelImport excelImport) {
        this.name = name;
        this.excelImport = excelImport;
    }

    public String getName() {
        return name;
    }

    public ExcelImport getExcelImport() {
        return excelImport;
    }

    public static ExcelImport getInstanceByName(String name) {
        for (ExcelImportEnum value : ExcelImportEnum.values()) {
            if (Objects.equals(name, value.getName())) {
                return value.getExcelImport();
            }
        }
        throw new IllegalArgumentException("name is not in this enum");
    }
}
